package edu.uniquindio.mispruebas;

import com.thoughtworks.selenium.Selenium;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
import org.testng.annotations.*;
import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium;

public class Pruebas {

	WebDriver driver;
	Selenium selenium;

	@BeforeMethod
	public void startSelenium() {
		driver = new FirefoxDriver();
		selenium = new WebDriverBackedSelenium(driver, "https://www.google.com.co/");
	}

	@AfterMethod
	public void stopSelenium() {
		driver.close();
	}

	@Test
	public void testPruebas() throws InterruptedException {
		selenium.open("/?gws_rd=ssl");
		selenium.type("id=gbqfq", "Selenium HQ");
		selenium.type("id=gbqfq", "Selenium HQ");
		for (int second = 0;; second++) {
			if (second >= 60) fail("timeout");
			try { if (selenium.isElementPresent("link=Selenium - Web Browser Automation")) break; } catch (Exception e) {}
			Thread.sleep(1000);
		}

		selenium.click("link=Selenium - Web Browser Automation");
		selenium.waitForPageToLoad("30000");
	}

	private void fail(String string) {
		// TODO Auto-generated method stub
		
	}

}
